package com.calciominoBeta.Activity;

import java.util.ArrayList;
import com.calciominoBeta.Entity.InfoOj;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

public class NgPageViewAdapter extends FragmentStatePagerAdapter {

	ArrayList<InfoOj> ojs;
	private Context context;

	public NgPageViewAdapter(FragmentManager fm, ArrayList<InfoOj> ojs,
			Context context) {
		super(fm);
		// TODO Auto-generated constructor stub
		this.ojs = ojs;
		this.context = context;
	}

	@Override
	public Fragment getItem(int position) {
		// lay type de lay biet duoc the loai nao,
		// neu ma type la video thif return
		// AQFragmentVideo.getInstance(ojs.get(position),context);
		String type = ojs.get(position).get(InfoOj.TYPE);
		if (type.equalsIgnoreCase("videos")) {
			return AQFragmentVideo.getInstance(ojs.get(position), context);
		}

		return AQFragmentDetail.getInstance(ojs.get(position), context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return ojs.size();
	}

	@Override
	public int getItemPosition(Object object) {
		// TODO Auto-generated method stub
		// MyFragment fragment = (MyFragment) object;

		return POSITION_UNCHANGED;
	}

}
